<?php

class Categoria{

	private $id;
	private $nome;
	public function __construct($id = 0,$nome= "" ){
		$this->id = $id;
		$this->nome = $nome;

	}

	public static function construct($array){
		return new Categoria( $array['id'], $array['nome']);

	}

	public function getId(){
		return $this->id;
	}

	public function setId($id){
		$this->id=$id;
	}

	public function getNome(){
		return $this->nome;
	}

	public function setNome($nome){
		$this->nome=$nome;
	}
	public function equals($object){
		if($object instanceof Categoria){

			if($this->id!=$object->id){
				return false;

			}

			if($this->nome!=$object->nome){
				return false;

			}

			return true;

		}
		else{
			return false;
		}

	}
	public function toString(){

		return "  [id:" .$this->id. "]  [nome:" .$this->nome. "]  " ;
	}
	public function toArray(){

		$temp =   (array) $this;

		$array = array();

		foreach ($temp as $k => $v){

			$k = preg_match('/^\x00(?:.*?)\x00(.+)/', $k, $matches) ? $matches[1] : $k;

			$array[$k] = $v;


		}
		return  $array;
	}

}
?>